﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using System.Data;

namespace DataAccess
{
    public class TaiKhoan_Info
    {
        public string manv { get; set; }
        public string hovaten { get; set; }
        public string matkhau { get; set; }
        public string chucvu { get; set; }
        public static List<TaiKhoan_Info> All()
        {
            return CBO.FillCollection<TaiKhoan_Info>(DataProvider.Instance.ExecuteReader("TaiKhoan_GetAll"));
        }
        public static DataSet GetAll()
        {
            return DataProvider.Instance.ExecuteDataset("TaiKhoan_GetAll");
        }
        public static TaiKhoan_Info Login(string manv, string matkhau)
        {
            try
            {
                return CBO.FillCollection<TaiKhoan_Info>(DataProvider.Instance.ExecuteReader("TaiKhoan_GetLogin", manv, matkhau))[0];
            }
            catch (Exception)
            {
                return null;
            }
        }
        public static bool Update(string manv, string matkhau)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("TaiKhoan_DoiMK", manv, matkhau);
                return Convert.ToInt32(rs) > 0;
            }
            catch (Exception e)
            {
                return BatLoi.ThongBao(e.Message);
            }

        }
        public static List<TaiKhoan_Info> GetByID(string manv)
        {
            return CBO.FillCollection<TaiKhoan_Info>(DataProvider.Instance.ExecuteReader("TaiKhoan_GetByID",manv));
        }
    }
}
